package com.hspedu.inputstream;

import com.hspedu.outputstream.Dog;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/2/25
 * @time 3:27
 */
public class ObjectInputStream_{
    public static void main (String[] args) throws IOException {
        String fileName = "D:\\BaiduNetdiskDownload\\韩顺平2021基础学Java\\temp\\news6.txt";

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(fileName));

        //序列化数据
        oos.writeInt(100);
        oos.writeBoolean(true);
        oos.writeChar('a');
        oos.writeDouble(9.5);
        oos.writeUTF("hspedu");

        oos.writeObject(new Dog("小黄",3));

        oos.close();
        System.out.println("数据保存完毕（序列化形式）");
    }
}
